//
//  AboutController.m
//  EncryPhone
//
//  Created by zhibao on 2022/6/16.
//

#import "AboutController.h"
@interface AboutController ()

@end

@implementation AboutController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.gk_navTitle = LocalizedString(@"关于我们");
    [self initView];
}

-(void)initView{
    UIImageView *imgView =[[UIImageView alloc]initWithFrame:CGRectMake(50,144 - 64 + NAVIH, 60, 60)];
    imgView.image = [UIImage imageNamed:@"me_logo"];
    [self.view addSubview:imgView];
    
    UILabel *ctiplabel = [[UILabel alloc]initWithFrame:CGRectMake(imgView.left, imgView.bottom + 16, MY_Screen_W - 100, 32)];
    ctiplabel.text = LocalizedString(@"盯盯水印相机");
    ctiplabel.font = MY_SCALE_SemiboldFONT(23);
    ctiplabel.textColor = UIColor.blackColor;
    [self.view addSubview:ctiplabel];
    
    UILabel *versionlabel = [[UILabel alloc]initWithFrame:CGRectMake(imgView.left, ctiplabel.bottom + 4, MY_Screen_W, 18)];
    NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];

    // 获取App的版本号
    NSString *appVersion = [infoDic objectForKey:@"CFBundleShortVersionString"];
    versionlabel.text = [NSString stringWithFormat:@"%@:%@", LocalizedString(@"当前版本 "),appVersion];
    versionlabel.font = MY_SCALE_RegularFONT(13);
    versionlabel.textColor = MyColor(@"999999");
    [self.view addSubview:versionlabel];
    
    UILabel *cshibielabel = [[UILabel alloc]initWithFrame:CGRectMake(imgView.left, versionlabel.bottom + 46, MY_Screen_W, 21)];
    cshibielabel.text = LocalizedString(@"识别号");
    cshibielabel.font = MY_SCALE_RegularFONT(15);
    cshibielabel.textColor = MyColor(@"333333");
    [self.view addSubview:cshibielabel];
    
    UILabel *shibielabel = [[UILabel alloc]init];
    NSString *onlyID = [DWKeychainTool getItemForKey:@"uuid"];
    shibielabel.text = onlyID;
    shibielabel.numberOfLines = 0;
    shibielabel.lineBreakMode = NSLineBreakByWordWrapping;
    shibielabel.font = MY_SCALE_RegularFONT(14);
    shibielabel.textColor = MyColor(@"999999");
    [self.view addSubview:shibielabel];
    [shibielabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(imgView);
        make.right.equalTo(self.view).offset(-80);
        make.top.equalTo(cshibielabel.mas_bottom).offset(7);
    }];
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.layer.cornerRadius = 10;
    btn.layer.borderColor = MyColor(@"#999999").CGColor;
    btn.layer.borderWidth = 0.5;
    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    [btn setTitle:LocalizedString(@"复制") forState:UIControlStateNormal];
    btn.titleLabel.font = MY_SCALE_RegularFONT(11);
    [btn setTitleColor:MyColor(@"999999") forState:UIControlStateNormal];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(shibielabel);
        make.top.equalTo(shibielabel.mas_bottom).offset(10);
        make.width.mas_equalTo(40);
        make.height.mas_equalTo(20);
    }];
    
    UIButton *beianBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [beianBtn setTitle:@"ICP备案号：京ICP备2022008219号-20A" forState:UIControlStateNormal];
    [beianBtn setTitleColor:MyColor(@"666666") forState:UIControlStateNormal];
    beianBtn.titleLabel.font = MY_SCALE_RegularFONT(11);
    [self.view addSubview:beianBtn];
    [beianBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.view);
        make.bottom.equalTo(self.view).offset(-SafeBottomMargin - 20);
    }];
    [beianBtn addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithActionBlock:^(id  _Nonnull sender) {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://beian.miit.gov.cn/"] options:@{} completionHandler:nil];
    }]];
}

-(void)btnClick{
    NSString *onlyID = [DWKeychainTool getItemForKey:@"uuid"];
    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
    pasteboard.string = onlyID;
    [QMUITips showSucceed:LocalizedString(@"已复制")];
}

@end
